<template>
  <div class="tuan">
      <van-nav-bar
          title="详情页"
          left-text="返回"
          right-text="..."
          left-arrow
          fixed
          @click-left="$router.go(-1)"
      />
      <div class="banner">
          <h1>爆爆团</h1>
          <h2>限时爆款 超级低价</h2>
      </div>
      
      <div class="ing">
          <span :class="{active:currentIndex==index}" v-for="(item,index) in arr" :key="index" @click="currentIndex=index">{{item}}</span>
      </div>
      <!-- 正在抢购-->
      <div v-show="currentIndex == 1">
          <div class="goods" v-for="(item,index) in goods" :key="index">
              <div class="imgBox">
                  <img :src="item.picture" alt="">
              </div>
              <div class="infor">
                  <span class="name">{{item.name}}</span>
                  <div class="price">
                      <span>￥{{item.min_price}}</span>
                      <button v-for="(item,index) in purchase" :key="index">{{item}}</button>
                  </div>
                  <div class="count">{{item.month_saled_content}}</div>
              </div>
          </div>
      </div>
      <!-- 上新预告 -->
      <div v-show="currentIndex == 0">
          <div class="goods" v-for="(item,index) in good" :key="index">
              <div class="imgBox">
                  <img :src="item.picture" alt="">
              </div>
              <div class="infor">
                  <span class="name">{{item.name}}</span>
                  <div class="price">
                      <span>￥{{item.min_price}}</span>
                      <button v-for="(item,index) in purchase" :key="index">{{item}}</button>
                  </div>
                  <div class="count">{{item.month_saled_content}}</div>
              </div>
          </div>
      </div>
      
  </div>
</template>

<script>
import {tuan_list} from "../../utils/api";
export default {
  data(){
      return{
          // go:true,
          currentIndex:0,
          arr:['正在抢购','上新预告'],
          purchase:['马上抢'],
          goods:[],
          good:[]
      }
  },
  methods:{
  change(){
          this.go=!this.go;
      }
  },
  mounted(){
      tuan_list( {status:1} ).then((res)=>{
          console.log(res.data);
          this.goods = res.data.list; 
      }),
      tuan_list( {status:0} ).then((res)=>{
          console.log(res.data);
           this.good = res.data.list; 
      })
  },
}
</script>

<style lang="scss" scoped>
.tuan{
  margin-top: 46px;
  background: #f5f5f5;
}
.banner{
  background: linear-gradient(red,orangered);
  opacity: 0.8;
  overflow: hidden;
  text-align: center;
}
h1{
  color: white;
  margin: 24px;
  font-size: 20px;
  margin-bottom: 30px;
}
h2{
  color: yellow;
  font-size: 30px;
  margin-bottom: 20px;
}
// 商品
.ing{
  background: linear-gradient(orangered,rgb(238, 193, 28));
  height: 50px;
  line-height: 50px;
}
.ing span{
  margin:0 20px;
  color: white;
}
.ing .active{
  border-bottom: 2px solid white;
}

.goods{
  margin: 10px;
  border-radius: 20px;
  background: white;
  overflow: hidden;
  display: flex;
}
.goods .imgBox{
  width: 80px;
  height: 80px;
  margin: 10px;
}
.goods .imgBox img{
  width: 100%;
  height: 100%;
  border-radius: 5px;
}
.goods .infor{
  flex: 1;
  margin: 10px;
}
.goods .infor .name{
  font-weight: bold;
  margin: 10px 0;
}
.goods .infor .price{
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.goods .infor .price span{
  font-size: 20px;
  margin: 10px 0;
  color:orangered;
}
.goods .infor .price button{
  height: 30px;
  width: 60px;
  border-radius: 10px;
  background: orangered;
  color: white;
  outline: none;
  border: none;
}
.goods .infor .count{
  float: right;
  margin: 10px;
}
</style>